<template>
	<view class="content">
		<!-- <rich-text v-if="content" :nodes="content"></rich-text>
		<text v-else>加载中...</text> -->
		<web-view :webview-styles="webviewStyles" :src="webUrl"></web-view>
	</view>
</template>

<script>
	import setting from "@/common/config.js";
	export default {
		data() {
			return {
				content: '',
				title: '',
				type: 1,
				setting,
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				webUrl: 'https://app.dianpower.cn/h5/privacy?type=PRIVACY_POLICY'
			};
		},
		onLoad({ type }) {
			this.type = type;
			if (type == 1) {
				this.webUrl = setting.privateUrl; // 隐私协议
			} 
			else if (type == 2) {
				this.webUrl = setting.serviceUrl; // 用户协议
			}
			this.fetchContent();
		},
		methods: {
			fetchContent() {
				this.$http_api.getArticle({
					id: this.type,
					title: this.title
				}).then(res => {
					this.content = res.content
				})
			}
		},
	}
</script>

<style scoped>
	.content {
		padding: 20rpx;
	}
</style>